<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_db.php';?>
<?php require_once 'dao/dao_news.php';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
	<div id="leftlay"><?php require_once 'leftnav.php';?></div>
	<div id="rightlay">
		<div class="columntitle"><?php echo NEWSMANANGE?></div>
		<div class="columncontent">
			<div id="weeklyreport">
			<div><a href="create_news.php"><?php echo NEWSPUBLIC?></a></div>
			<?php 	
				if($_SESSION['userid']!=''){
					if($_SESSION['level']==TEACHER||$_SESSION['level']==ADMINISTRATOR){
						$result=get_news_list($_SESSION['userid']);
						mysql_close();
					}
				}
				if(mysql_num_rows($result)!=0){		
			?>
				<table class="temptable">
				<tr>
					<th><?php echo REPORTTITLE?></th>
					<th><?php echo PUBLICDATE?></th>
					<th><?php echo NEWSTYPE?></th>
					<th><?php echo ACTION?></th>
				</tr>
				<?php 
					while(($row=mysql_fetch_array($result))!=false){
						$title=$row['TITLE'];
				?>
					<tr>
						<td width="300"><a href="news.php?nid=<?php echo $row['Id']?>" target="_blank"><?php echo $title?></a></td>
						<td width="80"><?php echo $row['NEWSDATE']?></td>	
						<td width="80"><?php echo get_news_type($row['NEWSTYPE'])?></td>
						<td width="80"><a href="service/service_save_news.php?id=<?php echo $row['Id']?>"><?php echo DEL?></a></td>
					</tr>
				<?php }?>
				</table>
			<?php 
				}else{
					echo NOREPORT;
				}
			?>
			</div>
		</div>
	</div>
</div>
</div>
</body>
</html>
<?php 
	function get_news_type($type){
		switch($type)
		{
			case GROUPMSGCODE:
				$showtype=GROUPNEWS;
				break;
			case STUDENTNOTICECODE:
				$showtype=STUDENTNOTICE;
				break;
			case JOBNEWSCODE:
				$showtype=JOBNEWS;
				break;
			case REPORTNEWSCODE:
				$showtype=REPORTNEWS;
				break;
		}
		return $showtype;
	}
?>
